import os

base_dir = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(base_dir, 'db2')

for item in os.listdir(db_path):
    print(item)

for item in os.walk(db_path):
    print(item)

# 一级目录
for name in os.listdir(db_path):
    file_path = os.path.join(db_path, name)
    print(name)
    print(file_path)

# 多级目录
base_dir = os.path.dirname(os.path.abspath(__file__))
db_path = os.path.join(base_dir, 'db')

for in_path, folder_list, name_list in os.walk(db_path):
    for name in name_list:
        abs_path = os.path.join(in_path, name)
        print(abs_path)
